<%--@elvariable id="answer" type="com.genghis.ptas.question.entity.Answer"--%>
<%--@elvariable id="questionId" type="java.lang"--%>
<%@ page contentType="text/html;charset=UTF-8" language="java" isELIgnored="false" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
    <meta http-equiv="X-UA-Compatible" content="IE=edge"/>
    <title>用户问题</title>
    <meta http-equiv="Content-Type" content="text/html;charset=UTF-8"/>
    <%@include file="../../includes/common.jsp" %>
</head>
<body>
<div id="mainContent">
    <form class="form-horizontal" action="">
        <fieldset>
            <legend></legend>

            <div class="control-group">
                <label class="control-label" for="answerContent">回答</label>

                <div class="controls">
                    <textarea id="answerContent" name="answerContent" cols=""
                              rows="">${answer.answerContent} </textarea>
                </div>
            </div>

            <div class="control-group">
                <label class="control-label"></label>

                <div class="controls">
                    <input type="button" id="saves" class="btn btn-primary" onclick="save()"
                           value="保存"/>
                    <input type="button" onclick="quit()" class="btn btn-primary"
                           value="取消"/>
                </div>
            </div>
        </fieldset>
    </form>
</div>
<div id="typeContent" class="divauto" style=" display:none; position: absolute;">
    <ul id="menuTree" class="ztree"></ul>
</div>
</body>
</html>
<script type="text/javascript">
    var rules = {
        objInfo: {
            answerContent: {
                checkEmpty: ["answerContent", "问题名称"]
            }
        }
    };

    function save() {
        if (!JC.validate(rules)) return;
        $("#saves").button('loading');
        $.ajax({
            url: basePath + "question/answer/editAnswerDo",
            data: {
                questionId:${questionId},
                id:${answer.id},
                answerContent: $("#answerContent").val().trim()
            },
            dataType: "json",
            type: "POST",
            success: function () {
                $.messager.alert("提示", "编辑成功！", "", function () {
                    parent.$("#dataEdit").dialog('close');
                    parent.findAnswer(${questionId});
                });
            },
            error: doError
        })
    }

    function quit() {
        parent.findAnswer(${questionId});
    }
</script>